<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('(超)危大工程清单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var prefix = ctx + "excellenceManage";
        var type = [[${type}]];

        $(function() {
            var options = {
                url: prefix + "/selectOfficeFileList?type="+type,
                removeUrl: prefix + "/removeInventory",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
                columns: [{
		            radio: true
		        },
				{
					field : 'fileName',
					title : '目标清单文件下载',
					formatter: function(value, row, index) {
						return '<a href="javascript:void(0)" onclick="downloadFile(\'' + row.fileName + '\')">清单文件下载</a>';
					}
				},
				{
					field : 'creater',
					title : '创建人'
				},
				{
					field : 'createTime',
					title : '创建时间'
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
                        var html = $.common.sprintf('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeInfo(\'' + row.fileId + '\')"><i class="fa fa-remove"></i>删除</a>', index, value);
                        return html;
					}
				}
		        ]
            };
            $.table.init(options);
        });

		// 删除按钮
        function removeInfo(fileId) {
            $.modal.confirm("确定删除该条记录吗？", function () {
                var config = {
                    url: prefix + "/removeExcellenceFile",
                    type: "post",
                    dataType: "json",
                    data: {"ids": fileId},
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                    },
                    success: function (result) {
                        if (typeof callback == "function") {
                            callback(result);
                        }
                        $.operate.ajaxSuccess(result);
                    }
                };
                $.ajax(config)

            });
        }

		// 下载清单按钮
        function downloadFile(value){
            window.location.href = "/common/download/resource?resource=" + value;
        }
    </script>
</body>
</html>